#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <stack>

using namespace std;


struct ListNode {
     int val;
    ListNode *next;
     ListNode(int x) : val(x), next(NULL) {}
};

class Solution1 {
public:
    vector<int> reversePrint(ListNode* head) {
        stack<int> s;
        vector<int> ans;
        ListNode* p=head;
        while(p){
            s.push(p->val);
            p=p->next;
        }
        while(!s.empty()){
            ans.push_back(s.top());
            s.pop();
        }
        return ans;
    }
};


//递归到链表最后面，然后在写入
class Solution {
    vector<int> res;
public:
    vector<int> reversePrint(ListNode* head) {
        res.clear();
        if(head){
            helper(head);
        }
        return res; 
    }
    void helper(ListNode* head){
        if(head->next==nullptr){
            res.push_back(head->val);
            return;
        }
        helper(head->next);
        res.push_back(head->val);
    }
};




int main(){




    return 0;
}